package com.job.client.common.rabbitmqConfig;
 
import com.job.client.model.rabbitmq.DraftConstant;
import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


@Configuration
/*
* 草稿箱rabbitmq配置
* */
public class RabbitmqDraftConfig {

//    @Bean(DraftConstant.EXCHANGE_DRAFT)
    @Bean
    public Exchange EXCHANGE_DRAFT(){
        return ExchangeBuilder
                .directExchange(DraftConstant.EXCHANGE_DRAFT) // 直连交换机，根据key匹配
                .durable(true).build();  // 持久化
    }

//    @Bean(DraftConstant.QUEUE_DRAFT_POSTS)
    @Bean
    public Queue QUEUE_DRAFT_POSTS(){
        return new Queue(DraftConstant.QUEUE_DRAFT_POSTS);
    }

    @Bean
    public Binding BINDING_QUEUE_DRAFT_POSTS(Queue QUEUE_DRAFT_POSTS,Exchange EXCHANGE_DRAFT){
        return BindingBuilder.bind(QUEUE_DRAFT_POSTS)
                .to(EXCHANGE_DRAFT)
                .with(DraftConstant.ROUTINGKEY_POSTS).noargs();
    }


}